#include "OpenGLBase.h"
#include <windows.h>
#include <GL\gl.h>
#include "glut.h"


OpenGLBase2D::OpenGLBase2D(char *windowName,int w,int h,void(*draw)())
{
	m_w = w;
	m_h = h;
	glutInit(0, NULL); 
	glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH); 
	glutInitWindowSize(m_w,m_h);  //Optionnel  
	glutCreateWindow(windowName); 
	glutReshapeFunc(Reshape);
	glutDisplayFunc(draw); 
	glutMainLoop();
}

OpenGLBase2D::~OpenGLBase2D()
{
}

void OpenGLBase2D::Reshape(int width, int height) 
{   
  m_w = width;
  m_h = height;
  glViewport(0,0,m_w,m_h); 
  glMatrixMode(GL_PROJECTION); 
  glLoadIdentity();  
  gluOrtho2D(0,m_w,0,m_h);
  glMatrixMode(GL_MODELVIEW);
  (*m_draw)();
}  
